﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoTest.Repository
{

    public class SqlSugarHelper
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbType">取值：SqlSugar.DbType枚举
        /// MySql
        /// SqlServer
        /// Sqlite
        /// Oracle
        /// PostgreSQL
        /// </param>
        /// <returns></returns>
        /// <exception cref="NotSupportedException"></exception>
        public static string GetConnectionStringFormat(string dbType)
        {
            return dbType switch
            {
                "MySql" => "Database={{database}};Data Source={{host}};Port={{port}};User Id={{user_name}};Password={{password}};Charset=utf8;TreatTinyAsBoolean=false;",
                "PostgreSQL" => "HOST={{host}};PORT={{port}};DATABASE={{dbname}};USER ID={{user_name}};PASSWORD={{password}}",
                "SqlServer" => "Data Source={{host}},{{port}};Initial Catalog={{dbname}};User Id={{username}};Password={{password}};Pooling=true;",
                "Oracle" => "data source={{host}}:{{port}}/{{dbname}};password={{password}};user id={{username}};Incr Pool Size=5;Decr Pool Size=2;",
                "Sqlite" => "",
                _ => throw new NotSupportedException($"暂不支持【{dbType}】数据库类型")
            };
        }
    }
}
